<template>

</template>

<script>
//const host = 'https://soapi.maixy.top';
const host = 'http://localhost:11111';
const mediaHost = 'https://media.maixy.top';
const avatarDefault = '/wode/avatar-default.png'
const avatar = '/wode/avatar.png'
const mp4Image = '/wode/mp4.png'
const pdfImage = '/wode/pdf.png'
const carousel = [mediaHost + '/wode/carousel1.jpg',mediaHost + '/wode/carousel2.jpg', mediaHost + '/wode/carousel1.jpg', mediaHost + '/wode/carousel2.jpg']
const headers =  {
  'Access-Control-Allow-Origin': '*',
  'Content-Type': 'application/json;charset=UTF-8'
}
const fileHeaders =  {
  'Access-Control-Allow-Origin': '*',
  'Content-Type': 'multipart/form-data'
}
const indexPage = {
  lastValue: 0,
  size: 10,
  totalPage: 0,
  hasMore: false,
  page: 1,
  totalCount: 0
}
const userBasisInfoView = {
  teamCreateByName : '',
  hasTeamCreateBy : true,
  teamUserCount : 0,
  activityNum : 0,
  joinActivityNum : 0
}
const imageType = 'image'
const videoType = 'video'
const pdfType = 'pdf'
const bucket= '1111111'
// region以杭州为例（oss-cn-hangzhou），其他region按实际情况填写。
const region= 'oss-cn-guangzhou'
// 阿里云主账号AccessKey拥有所有API的访问权限，风险很高。强烈建议您创建并使用RAM账号进行API访问或日常运维，请登录RAM控制台创建RAM账号。
const accessKeyId= '111111'
const accessKeySecret= '11111111'
function getUser() {
  return JSON.parse(localStorage.getItem("user"))
}
function getTeamId() {
  return localStorage.getItem("teamId")
}
function setUser(user) {
  localStorage.setItem("user",JSON.stringify(user))
}
function setTeamId(teamId) {
  localStorage.setItem("teamId",teamId)
}
function removeUser() {
  localStorage.removeItem("user")
}
function removeTeamId() {
  localStorage.removeItem("teamId")
}
function getTabIndex() {
  return sessionStorage.getItem("tabIndex")
}
function setTabIndex(tabIndex) {
  sessionStorage.setItem("tabIndex",tabIndex)
}
function removeTabIndex() {
  sessionStorage.removeItem("tabIndex")
}
function randomStr(length) {
  const str ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  let sb= ""
  for(let i=0; i<length; i++){
    //生成0~62的数字，包含0不包含62
    let number = Math.round(Math.random() * 62)
    sb += str.charAt(number)
  }
  return sb.toString();
}
function checkSpecificKey(str) {
  const specialKey = " [`~!#$^&*()=|{}':;',\\[\\].<>/?~！#￥……&*（）——|{}【】‘；：”“'。，、？]‘'";
  for (let i = 0; i < str.length; i++) {
    if (specialKey.indexOf(str.substr(i, 1)) !== -1) {
      return false;
    }
  }
  return true;
}

export default {
  name: "Global",
  host,
  mediaHost,
  avatarDefault,
  avatar,
  mp4Image,
  pdfImage,
  carousel,
  headers,
  fileHeaders,
  indexPage,
  userBasisInfoView,
  imageType,
  videoType,
  pdfType,
  bucket,
  region,
  accessKeyId,
  accessKeySecret,
  getUser,
  setUser,
  removeUser,
  getTeamId,
  setTeamId,
  removeTeamId,
  getTabIndex,
  setTabIndex,
  removeTabIndex,
  randomStr,
  checkSpecificKey
}
</script>

<style scoped>

</style>
